<div class="table-p"><table class="table">
  <thead>
    <tr>
      {% for k, f in fields.items() %}
      <th class="{{k}}{{' text-'+f['align'] if f.get('align') else ''}}">{{f['caption']}}</th>
      {% end %}
      {% if model.actions %}
      <th class="actions">操作</th>
      {% end %}
    </tr>
  </thead>
  <tbody>
    {% for r in rows %}
    {% set url0 = [util.sub_prop(c.get('url'), r) for c in model.actions if c.get('default')] %}
    <tr id="{{r['_id']}}">
      {% for k, f in fields.items() %}
      <td class="{{k}}{{' text-'+f['align'] if f.get('align') else ''}}">
        {% if f.get('type') == 'user' %}
        {% module Users([r[k]]) %}
        {% elif k == 'name' and url0 and url0[0] %}
        <div><a href="{{url0[0]}}">{{r.get(k, '')}}</a></div>
        {% else %}
        <div>{{r.get(k, '')}}</div>
        {% end %}
      </td>
      {% end %}
      {% if model.actions %}
      <td class="actions">
        {% for c in model.actions %}
        {% set href='url' in c and util.sub_prop(c['url'], r) or '#' %}
        <a href="{{href}}" target="{{ '_blank' if 'proj/view/' in href else '_self' }}" class="btn btn-default">{{c['caption']}}</a>
        {% end %}
      </td>
      {% end %}
    </tr>
    {% end %}
  </tbody>
</table></div>
{% if not rows %}
<p class="center gray m-t-n10">表格没有内容</p>
{% end %}
